import copy


class MobilePhone:
    def __init__(self, cpu):
        self.cpu = cpu


class CPU:
    pass


c = CPU()
m1 = MobilePhone(c)
m2 = m1
print(
    "【直接赋值】c: {}, m1: {}, m2: {},  m1.cpu: {}, m2.cpu: {}".format(
        id(c), id(m1), id(m2), id(m1.cpu), id(m2.cpu)
    )
)

# --- 浅拷贝
c = CPU()
m1 = MobilePhone(copy.copy(c))
m2 = copy.copy(m1)
print(
    "【浅拷贝】c: {}, m1: {}, m2: {},  m1.cpu: {}, m2.cpu: {}".format(
        id(c), id(m1), id(m2), id(m1.cpu), id(m2.cpu)
    )
)

# --- 深拷贝
c = CPU()
m1 = MobilePhone(copy.deepcopy(c))
m2 = copy.deepcopy(m1)
print(
    "【深拷贝】c: {}, m1: {}, m2: {},  m1.cpu: {}, m2.cpu: {}".format(
        id(c), id(m1), id(m2), id(m1.cpu), id(m2.cpu)
    )
)
